package com.ch.controller;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.ch.pojo.SmbmsUser;
import com.ch.service.CarService;
import com.ch.service.SmbmsUserService;




@Controller
@RequestMapping("/controller")
public class CarController {
	
	@Autowired
	private CarService CarSer;
	
	@Autowired
	private SmbmsUserService userSer;
	
	
	@RequestMapping("/car")
	public String byCar(){
		System.out.println("我想做汽车！");
		return null;
	}
	
	//返回页面
	@RequestMapping("/bus")
	public String byBus(Integer id,Model mo){
		
		System.out.println("传过来的id是："+id);
		String name = CarSer.Cars(id);
		mo.addAttribute("names", name);
		return "index2";
	}
	
	//返回页面
	@RequestMapping("/busname")
	public String byBusName(String names,Model mo){
			
		System.out.println("传过来的id是："+names);
		mo.addAttribute("names2", names);
		return "index2";
	}
	
	//
	@RequestMapping("/myid/{}")
	public String del(){
		
		return null;
	}
	
	@RequestMapping("/findUsesr")
	public String findUser(){
		List<SmbmsUser> users = userSer.findUser();
		for (SmbmsUser u : users) {
			System.out.println(u.getAddress());
		}
		return null;
	}
}
